﻿var wcsBaseUrl = "http://127.0.0.1:12138/";
craneList=[];
lastTasks={};
pathTask={};
var xmlHttpReg = null;
var xmlHttpReg1 = null;
if (window.ActiveXObject) {//如果是IE
    xmlHttpReg = new ActiveXObject("Microsoft.XMLHTTP");
    xmlHttpReg1 = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
    xmlHttpReg = new XMLHttpRequest(); //实例化一个xmlHttpReg
    xmlHttpReg1 = new XMLHttpRequest(); //实例化一个xmlHttpReg
}





    

function myLoadData(url,fun1,err1){
		xmlHttpReg1.onreadystatechange = function () {
			if(xmlHttpReg1.readyState == 4){
						if (  xmlHttpReg1.status == 200) {//4代表执行完成
			        var res= JSON.parse(xmlHttpReg1.responseText)
			        fun1(res);
		        }else if(xmlHttpReg1.status == 0||xmlHttpReg1.status == 404 ){
				    	err1&&err1(xmlHttpReg1.status)
				    }
				}
        
    }
		xmlHttpReg1.open("get", wcsBaseUrl+url, true);
		xmlHttpReg1.send();

	
	}
function myReflash(url,fun,err){

		this.url=wcsBaseUrl+url;
		var doResult = function () {
			if(xmlHttpReg.readyState == 4){
				
						if (  xmlHttpReg.status == 200) {//4代表执行完成
			        var res= JSON.parse(xmlHttpReg.responseText)
			        try{
			        	  fun(res)
			        }catch(e){
			        		err&&err(e)
			        }
			      
		        }else if(xmlHttpReg.status == 0||xmlHttpReg.status == 404 ){
				    	err&&err(xmlHttpReg.status)
				    }
				 		setTimeout(ajax, 500);
				}
        
    }
		var ajax= function(){
			 xmlHttpReg.open("get", this.url, true);
				try{

					xmlHttpReg.send();
					xmlHttpReg.onreadystatechange = doResult; //设置回调函数
				}catch(e){
						
					  err&&err(e)
						setTimeout(ajax, 1000);
				}
	   }

			ajax();
	}
	
	
	
	
	
	